var geoCoordMap = {
    "武汉": ["114.31", "30.52"],
    "武昌": ["114.33", "30.35"],
    "汉阳": ["114.02", "30.57"],
    "黄石": ["115.09", "30.2"],
    "十堰": ["110.79", "32.65"],
    "沙市": ["112.24", "30.32"],
    "宜昌": ["111.3", "30.7"],
    "襄樊": ["112.14", "30.02"],
    "孝感": ["113.91", "31.92"],
    "黄陂": ["114.36", "30.88"],
    "汉川": ["113.59", "30.63"],
    "云梦": ["113.73", "31.02"],
    "应山": ["113.81", "31.62"],
    "大悟": ["114.09", "31.56"],
    "应城": ["113.6", "30.94"],
    "安陆": ["113.69", "31.25"],
    "鄂城": ["114.87", "30.38"],
    "黄冈": ["114.87", "30.44"],
    "新洲": ["114.8", "31.84"],
    "红安": ["114.61", "31.29"],
    "麻城": ["115", "31.17"],
    "罗川": ["115.37", "30.79"],
    "浠水": ["115.22", "30.46"],
    "蕲春": ["115.3", "30.24"],
    "黄梅": ["115.93", "30.09"],
    "广济": ["115.56", "29.85"],
    "英山": ["115.57", "30.75"],
    "咸宁": ["114.28", "29.87"],
    "阳新": ["115.22", "29.83"],
    "通山": ["114.52", "29.6"],
    "通城": ["113.8", "29.23"],
    "嘉鱼": ["113.91", "29.97"],
    "崇阳": ["114.04", "29.54"],
    "蒲圻": ["113.85", "29.71"],
    "荆门": ["112.19", "31.02"],
    "江陵": ["112.18", "30.35"],
    "钟祥": ["112.58", "31.17"],
    "京山": ["113.11", "31.03"],
    "监利": ["112.9", "29.83"],
    "石首": ["112.41", "29.73"]
}
var objJson = [{
    "name": "汉南区",
    "position": [114.095513945313, 30.3156740546875],
    "value": 99
}, {
    "name": "汉阳区",
    "position": [114.287345, 30.563843],
    "value": 62
}, {
    "name": "东西湖区",
    "position": [114.242430449219, 30.6680153632813],
    "value": 43
}, {
    "name": "蔡甸区",
    "position": [114.041883574219, 30.6203249335938],
    "value": 95
}, {
    "name": "硚口区",
    "position": [114.258377714844, 30.5913161445313],
    "value": 37
}, {
    "name": "洪山区",
    "position": [114.313985625, 30.5523195625],
    "value": 90
}, {
    "name": "黄陂区",
    "position": [114.464346953125, 30.7278957343751],
    "value": 54
}, {
    "name": "江岸区",
    "position": [114.347345, 30.643843],
    "value": 51
}, {
    "name": "江汉区",
    "position": [114.297345, 30.583843],
    "value": 28
}, {
    "name": "江夏区",
    "position": [114.525152617188, 30.0272658515625],
    "value": 59
}, {
    "name": "青山区",
    "position": [114.431790800781, 30.6082888007812],
    "value": 40
}, {
    "name": "武昌区",
    "position": [114.313985625, 30.5523195625],
    "value": 89
}, {
    "name": "新洲区",
    "position": [114.481910429688, 30.7365407539063],
    "value": 56
}]
var geoCoordMap = {
    "武汉": {
        "position": ["114.31", "30.52"],
        "value": 388,
        "childrens": [

        ]
    }
}
var convertData = function(data) {
    var res = [];
    alert(2)
    console.log(data)
    for (var i = 0; i < data.length; i++) {
        var geoCoord = geoCoordMap[data[i].name];
        if (geoCoord) {
            res.push({
                name: data[i].name,
                value: geoCoord.position.concat(data[i].value)
            });
        }
    }
    console.log(res)
    return res;
};

var provinces = {
    //23个省
    "台湾": "taiwan",
    "河北": "hebei",
    "山西": "shanxi",
    "辽宁": "liaoning",
    "吉林": "jilin",
    "黑龙江": "heilongjiang",
    "江苏": "jiangsu",
    "浙江": "zhejiang",
    "安徽": "anhui",
    "福建": "fujian",
    "江西": "jiangxi",
    "山东": "shandong",
    "河南": "henan",
    "湖北": "hubei",
    "湖南": "hunan",
    "广东": "guangdong",
    "海南": "hainan",
    "四川": "sichuan",
    "贵州": "guizhou",
    "云南": "yunnan",
    "陕西": "shanxi1",
    "甘肃": "gansu",
    "青海": "qinghai",
    //5个自治区
    "新疆": "xinjiang",
    "广西": "guangxi",
    "内蒙古": "neimenggu",
    "宁夏": "ningxia",
    "西藏": "xizang",
    //4个直辖市
    "北京": "beijing",
    "天津": "tianjin",
    "上海": "shanghai",
    "重庆": "chongqing",
    //2个特别行政区
    "香港": "xianggang",
    "澳门": "aomen"
};

//直辖市和特别行政区-只有二级地图，没有三级地图
var special = ["北京", "天津", "上海", "重庆", "香港", "澳门"];
var mapdata = [];
//绘制全国地图
$.getJSON('static/map/province/hubei.json', function(data) {
    d = [];
    for (var i = 0; i < data.features.length; i++) {
        d.push({
            name: data.features[i].properties.name,
        })
    }
    mapdata = d;
    //注册地图
    echarts.registerMap('hubei', data);
    //绘制地图
    renderMap('hubei', d);
});

// var geoCoordMap = {

//     "武汉": [114.31, 30.52]
// };
var resJson = [{
    "name": "汉南区",
    "value": [114.095513945313, 30.3156740546875, 99]
}, {
    "name": "汉阳区",
    "value": [114.287345, 30.563843, 62]
}, {
    "name": "东西湖区",
    "value": [114.242430449219, 30.6680153632813, 43]
}, {
    "name": "蔡甸区",
    "value": [114.041883574219, 30.6203249335938, 95]
}, {
    "name": "硚口区",
    "value": [114.258377714844, 30.5913161445313, 37]
}, {
    "name": "洪山区",
    "value": [114.313985625, 30.5523195625, 90]
}, {
    "name": "黄陂区",
    "value": [114.464346953125, 30.7278957343751, 54]
}, {
    "name": "江岸区",
    "value": [114.347345, 30.643843, 51]
}, {
    "name": "江汉区",
    "value": [114.297345, 30.583843, 28]
}, {
    "name": "江夏区",
    "value": [114.525152617188, 30.0272658515625, 59]
}, {
    "name": "青山区",
    "value": [114.431790800781, 30.6082888007812, 40]
}, {
    "name": "武昌区",
    "value": [114.313985625, 30.5523195625, 89]
}, {
    "name": "新洲区",
    "value": [114.481910429688, 30.7365407539063, 56]
}]
var convertData = function(data) {
    var res = [];
    for (var i = 0; i < data.length; i++) {
        var geoCoord = geoCoordMap[data[i].name];
        if (geoCoord) {
            res.push({
                name: data[i].name,
                value: geoCoord.position.concat(data[i].value)
            });
        }
    }
    return resJson;
};